package com.jymj.utils.FileUtile;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;

/**
 * 上传文件通用类
 * @author Lzh
 * @date 2021/7/16 15:21
 */
@Data
@Accessors(chain = true)
@NoArgsConstructor
public class FileUploadEntity implements Serializable {
    private static final long serialVersionUID = -8651436965074593489L;
    private Long fileId;//被上传文件的id 需要单独set
    private String url;//完整url
    private String path;//完整路径
    private String dataUrl;//数据库储存url
    private String dataPath;//数据库储存路径
    private String urlHead;//url前缀
    private String pathHead;//路径前缀
    private String uploadType;//上传类型 确定上传文件的源文件夹
    private String fileName;//文件名
    private Integer fileType;//文件类型
    private PathUtiles pathUtiles;
    public FileUploadEntity(String pathHead) {
        this.pathUtiles = new PathUtiles().PathUtilesInit(pathHead);
    }

    public String getUrl() {
        return getUrlHead() + dataUrl;
    }

    public String getPath() {
        return pathUtiles.getPath();
    }

    public String getUrlHead() {
        return pathUtiles.getUrl();
    }

    public String getPathHead() {
        return pathUtiles.getPath();
    }
    public String getUploadType(){
        return pathUtiles.getPathHead();
    }

}
